/*
 * @Author: zhumeng@sensorsdata.cn
 * @Date: 2024-04-03 20:18:55
 * @LastEditTime: 2024-04-03 20:21:07
 * @Description:
 */
import React from 'react'
import {
  Table,
  TableHeader,
  TableColumn,
  TableBody,
  TableRow,
  TableCell,
  getKeyValue
} from '@nextui-org/react'

export default function QTable(props) {
  const { rows = [], columns = [] } = props

  return (
    <Table aria-label="table with dynamic content">
      <TableHeader columns={columns}>
        {(column) => <TableColumn key={column.key}>{column.label}</TableColumn>}
      </TableHeader>
      <TableBody items={rows}>
        {(item) => (
          <TableRow key={item.key}>
            {(columnKey) => (
              <TableCell>{getKeyValue(item, columnKey)}</TableCell>
            )}
          </TableRow>
        )}
      </TableBody>
    </Table>
  )
}
